package com.xbongbong.paas.model.impl;

import com.xbongbong.paas.domain.dao.PaasProcessRelatedDataDao;
import com.xbongbong.paas.domain.entity.PaasProcessRelatedDataEntity;
import com.xbongbong.paas.model.PaasProcessRelatedDataModel;
import com.xbongbong.paas.toolbox.util.DateUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author: lee
 * @date: 2020/07/14 14:39
 * @desrcption: 流程中间数据
 */
@Service("paasProcessRelatedDataModel")
public class PaasProcessRelatedDataModelImpl implements PaasProcessRelatedDataModel {

    @Resource
    private PaasProcessRelatedDataDao paasProcessRelatedDataDao;


    @Override
    public Integer insert(PaasProcessRelatedDataEntity entity) {
        long now = DateUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        return paasProcessRelatedDataDao.insert(entity);
    }

    @Override
    public List<PaasProcessRelatedDataEntity> list(Map<String, Object> entity) {
        return paasProcessRelatedDataDao.findEntitys(entity);
    }

    @Override
    public PaasProcessRelatedDataEntity getByKey(Integer key, String corpid) {
        return paasProcessRelatedDataDao.getByKey(key, corpid);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> entity) {
        return paasProcessRelatedDataDao.getEntitysCount(entity);
    }

    @Override
    public Integer delete(PaasProcessRelatedDataEntity entity) {
        return paasProcessRelatedDataDao.deleteByKey(entity.getId().intValue(), entity.getCorpid());
    }

    @Override
    public Integer update(PaasProcessRelatedDataEntity entity) {
        long now = DateUtil.getInt();
        entity.setUpdateTime(now);
        return paasProcessRelatedDataDao.update(entity);
    }

    @Override
    public void insertBatch(List<PaasProcessRelatedDataEntity> entityList) {
        paasProcessRelatedDataDao.insertBatch(entityList);
    }

    @Override
    public List<PaasProcessRelatedDataEntity> getByTaskId(Long key, String corpid) {
        return paasProcessRelatedDataDao.getByTaskId(key, corpid);
    }

    @Override
    public List<PaasProcessRelatedDataEntity> findEntitys(Map<String, Object> param) {
        return paasProcessRelatedDataDao.findEntitys(param);
    }

    @Override
    public void deleteByTaskId(Long taskId, String corpid) {
        paasProcessRelatedDataDao.deleteByTaskId(taskId, corpid);
    }

    @Override
    public void updateFlowStatusByTaskId(Long taskId, String corpid, Integer flowStatus) {
        paasProcessRelatedDataDao.updateFlowStatusByTaskId(taskId, corpid, flowStatus);
    }

    @Override
    public List<PaasProcessRelatedDataEntity> getByRefIdAndBusinessType(Long refId, Integer businessType, String corpid) {
        return paasProcessRelatedDataDao.getByRefIdAndBusinessType(refId, businessType, corpid);
    }

}
